|
|
 |
|
|
|
|
End With
Polygon pic.hdc, api_points(1), 4
Next j
Next i
End Sub |
|
|
|
|
|
|
|
|
Example program ZOrder uses the ZOrderGrid3d class to display surfaces. Use the option buttons to select the surface you want to see. Use the check box to determine whether the program removes the hidden surfaces. |
|
|
|
|
|
|
|
|
Using a straightforward fractal technique, you can turn a simple surface into an interesting, irregular terrain. Start with any simple surface modeled as a grid. Break each bent rectangle that makes up the surface into four smaller rectangles as shown on the left in Figure 14.15. Initially, set the Y coordinates of each of the five newly created points to be the averages of the surrounding points. For example, if y1 and y2 are the Y coordinates of two adjacent corners in the original rectangle, set the Y coordinate of the point between them to (y1 + y2)/2. |
|
|
|
|
|
|
|
|
Next, modify each of the new Y coordinates by a small random amount. This gives you a set of four new bent rectangles like the ones shown on the right in Figure 14.15. |
|
|
|
|
|
|
|
|
By breaking up all the regions representing the original surface, you create a new, slightly randomized surface containing four times as many regions. You can then recursively break up the new regions into smaller and smaller regions until you have reduced them to some acceptable size. |
|
|
|
|
|
|
|
|
Figures 14.16 and 14.17 show surfaces that were created pseudo-randomly and drawn through use of the Hi-Lo algorithm. The data for Figure 14.16, for example, was created with code similar to the code that follows. The first Cos term gives the surface a ridge down the middle, parallel to the X axis. The next two Sin terms give the ridge some bumps of different sizes. The final Rnd term gives the basic surface a bit of randomness. |
|
|
|
|
|
|
|
|
Figure 14.15
Subdividing a region on a surface. |
|
|
|
|
|